<?php
include('includes/functions.php');
$title = "Pending Moderation";
include('includes/header.php');
if (!is_admin($_SESSION['UserID'])) {
	header('Location: /calendar/');
}
if ($_GET['action'] == "approve_event") approve_event($_GET['id']);
if ($_GET['action'] == "approve_user") approve_user($_GET['id']);
if ($_GET['action'] == "remove_event") remove_event($_GET['id']);
if ($_GET['action'] == "approve_feed") approve_feed($_GET['id']);
if ($_GET['action'] == "remove_feed") remove_feed($_GET['id']);
?>
<?php $events = get_pending_events(); 
if (sizeof($events)>0) { ?>
<h3>Pending Events</h3>
<ul>
	<?php foreach ($events as $event) { 
	$user = get_user(get_user_by_event($event['id']));
	?>
		<li><a href='/calendar/<?php echo $date . "/" . $event['slug']; ?>/?height=300&width=450' title='<?php echo $event['title']; ?>' class="thickbox" > <?php echo $event['title']; ?></a> added by <?php echo $user['email']; ?> [ <a href='?action=approve_event&id=<?php echo $event['id']; ?>'>Approve Event </a> | <a href='?action=approve_user&id=<?php echo $user['id']; ?>'>Approve User </a>  | <a href='?action=remove_event&id=<?php echo $event['id']; ?>'>Remove Event </a>]</li>
	<?php } ?>
</ul>
<?php } else { ?>
<p><i>No Events Pending at this Time</i></p>
<?
}
$feeds = get_pending_feeds(); 
if (sizeof($feeds)>0) { ?>
<h3>Pending Calendars</h3>
<ul>
	<?php foreach ($feeds as $feed) { 	?>
		<li><?php echo $feed['name']; ?> [ <a href='?action=approve_feed&id=<?php echo $feed['id']; ?>'>Approve Calendar </a> | <a href='?action=remove_feed&id=<?php echo $feed['id']; ?>'>Remove Calendar </a> ]</li>
	<?php } ?>
</ul>
<?php } else { ?>
<p><i>No Calendars Pending at this Time</i></p>
<?
}
include('includes/footer.php');
?>